<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var qSort = function(nums) {
    if(!nums) return []
    // 寻找到中间数字
    var res = Math.floor(nums.length/2)
    // 将数组分开
    let mid = nums.splice(res,1)[0]

    let left = []
    let right = []
    // 
    for(let i = 0 ; i< nums.length ; i ++) {
        if(nums[i]<mid) {
            left.push(nums[i])
        }
        else {
            right.push(nums[i])
        }

    }
    return qSort(left).concat(qSort(right),mid)

}
let arr = [1,35,8,6,9]
let res = qSort(arr)
console.log(res);
</script>
</html>